﻿using System.Data;

namespace DAL
{
    public static class DalCashFund
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable CashFundGet(string keywords)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@KEYWORDS", keywords);
            return Cls.GetData("sp_Cash_Fund_Get");
        }
        public static DataTable CashFundGetEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_CashFund", id);
            return Cls.GetData("sp_Cash_Fund_Get_Edit");
        }
        public static DataTable SumCashFund()
        {
            Cls.CreateNewSqlCommand();
            return Cls.GetData("sp_Cash_Fund_Sum");
        }
        public static DataTable SumCashFundReportReceipt()
        {
            Cls.CreateNewSqlCommand();
            return Cls.GetData("sp_Cash_Fund_Sum_Report_Receipt");
        }
        public static DataTable CashFundGetFillter(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Bank_Account_ID", id);
            return Cls.GetData("sp_Cash_Fund_Fillter");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtCashFund obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Bank_Account_ID", obj.Bank_Account_ID);
            Cls.AddParameter("@Cash_Fund_Code", obj.Cash_Fund_Code);
            Cls.AddParameter("@Cash_Fund_Name", obj.Cash_Fund_Name);
            Cls.AddParameter("@Amount_Original", obj.Amount_Original);
            Cls.AddParameter("@Amount_Current", obj.Amount_Current);
            return Cls.ExecuteNonQuery("sp_Cash_Fund_Insert");
        }
        public static bool Update(EtCashFund obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_CashFund", obj.ID_CashFund);
            Cls.AddParameter("@Bank_Account_ID", obj.Bank_Account_ID);
            Cls.AddParameter("@Cash_Fund_Code", obj.Cash_Fund_Code);
            Cls.AddParameter("@Cash_Fund_Name", obj.Cash_Fund_Name);
            Cls.AddParameter("@Amount_Original", obj.Amount_Original);
            Cls.AddParameter("@Amount_Current", obj.Amount_Current);
            return Cls.ExecuteNonQuery("sp_Cash_Fund_Update");
        }
        public static bool Delete(EtCashFund obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_CashFund", obj.ID_CashFund);
            return Cls.ExecuteNonQuery("sp_Cash_Fund_Delete");
        }
        #endregion
    }

    public class EtCashFund
    {
        public int ID_CashFund { get; set; }
        public int ? Bank_Account_ID { get; set; }
        public float ? Amount_Original { get; set; }
        public float ? Amount_Current { get; set; }
        public float ? Amount_Profit { get; set; }
        public string Cash_Fund_Code { get; set; }
        public string Cash_Fund_Name { get; set; }
    }
}
